﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class TypeDeclarationElement : IdElement
    {
        private bool typed;
        private ITypeElement definition;

        public bool Typed { get { return typed; } set { typed = value; } }
        public ITypeElement Definition { get { return definition; } set { definition = value; } }

        public TypeDeclarationElement(TokenInfo Id, bool Typed, ITypeElement Definition, List<TokenInfo> Comments)
            : base(Id, Comments)
        {
            id = Id;
            typed = Typed;
            definition = Definition;
        }

        public override string ToString()
        {
            return string.Format("{0} = {1}{2};", base.ToString(), (typed) ? "type " : string.Empty, definition);
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            yield return definition;
        }
    }
}
